<template>
    <div class="center-main-wrap">
        <div class="center-main-nav">
            <div class="nav-item" :class="{ 'nav-item-active': $route.path == item.url }" @click="toLinkFun(item)" v-for="(item, index) in navList" :key="index">
                <span>{{ item.name }}</span>
                <i class="el-icon-arrow-right"></i>
            </div>
        </div>
        <div class="center-main-content">
            <router-view></router-view>
        </div>
    </div>
</template>

<script>

export default {
    data() {
        return {
            navList: [{
                name: '个人信息',
                url: '/center/info'
            }, {
                name: '我的论坛',
                url: '/center/forum'
            }, {
                name: '知识库收藏',
                url: '/center/study'
            }, {
                name: '账号安全',
                url: '/center/safe'
            }, {
                name: '我的积分',
                url: '/center/point'
            }],
        }
    },
    computed:{},
    mounted() {

    },
    methods: {
        // 跳转链接
        toLinkFun(item) {
            if(this.$route.path == item.url) return false;
            this.$router.replace(item.url);
        }
    }
}
</script>

<style lang="less">
.center-main-wrap {
    .head {
        display: flex;
        align-items: center;
        padding-left: 0.5rem;
        box-sizing: border-box;
        width: 100%;
        height: 0.9rem;
        background: rgba(105, 115, 128, 0.1);
        font-size: 0.2rem;
        color: #333;
        margin-bottom: 0.2875rem;
    }
}
</style>

<style lang="less" scoped>
.center-main-wrap {
    display: flex;
    align-items: flex-start;
    padding-top: 0.6rem;
    padding-bottom: 0.6rem;

    .center-main-nav {
        width: 3rem;
        box-shadow: 0px 0.0375rem 0.1875rem 0.0125rem rgba(0, 0, 0, 0.06);

        .nav-item {
            position: relative;
            display: flex;
            align-items: center;
            justify-content: space-between;
            box-sizing: border-box;
            padding: 0 0.5rem 0 0.5rem;
            width: 100%;
            height: 0.9rem;
            font-size: 0.2rem;
            color: #333;
            cursor: pointer;
            user-select: none;
        }

        .nav-item-active {
            background: rgba(#4F8AF8, 0.1);

            &::before {
                content: '';
                display: block;
                position: absolute;
                left: 0;
                top: 0;
                width: 0.15rem;
                height: 0.9rem;
                background: #4F8AF8;
                border-radius: 0px 0.05rem 0.05rem 0px
            }
        }
    }

    .center-main-content {
        flex: 1;
        padding-left: 0.5rem;

    }
}</style>